home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ian & Stuart's Australian Mac: Not for Sale
/
Another.not.for.sale (Australia).iso
/
fade into you
/
getting there
/
TCP⁄PPP⁄SLIP
/
TCP⁄IP Scripting Addition 1.1.2
/
Examples 1.2
/
Text Versions
/
Send Mail (text)
< prev
Wrap
Text File
|
1994-09-18
|
3KB
|
87 lines
(*
Send Mail Script 1.1
Copyright © 1994 by Atul Butte. All Rights Reserved.
Sends a test e–mail message to your account. Improvements by Roel Vertegaal.
*)
on run
set dialog_response to (display dialog "Enter the name of the machine where you read e-mail" default answer "")
if (button returned of dialog_response ≠ "OK") then
return
else
set email_host to text returned of dialog_response
end if
set dialog_response to (display dialog "Enter your e-mail address on " & email_host default answer "")
if (button returned of dialog_response ≠ "OK") then
return
else
set email_address to text returned of dialog_response
end if
set dialog_response to (display dialog "Enter a subject for this message" default answer "")
if (button returned of dialog_response ≠ "OK") then
return
else
set email_subject to text returned of dialog_response
end if
send_message(email_host, email_address, email_subject)
end run
on send_message(email_host, email_address, email_subject)
set LF to ASCII character (10)
set CR to return
set CRLF to CR & LF
set sss to (tcp connect to host email_host port 25)
try
readresponse(sss)
tcp write data "mail from: applescript@[" & local host of (tcp status stream sss) & "]" & return ¬
stream sss using ISO88591
readresponse(sss)
tcp write data "rcpt to: " & email_address & return ¬
stream sss using ISO88591
readresponse(sss)
tcp write data "data" & return stream sss using ISO88591
readresponse(sss)
tcp write data "To: " & email_address & "@" & email_host & return stream sss using ISO88591
tcp write data "Subject: " & email_subject & return stream sss using ISO88591
tcp write data "This is a test message from AppleScript." & return stream sss using ISO88591
tcp write data "." & return stream sss using ISO88591
readresponse(sss)
tcp close stream sss
return
on error msg number num
tcp close stream sss
display dialog "Error: " & msg & " " & num
end try
end send_message
on readresponse(sstream)
set LF to ASCII character (10)
set continuechar to "-"
set wholemessage to ""
repeat until continuechar = " "
repeat until (tcp ahead characters LF stream sstream)
end repeat
set readline to (tcp read until characters LF stream sstream using ISO88591)
set scan to (scanline(readline))
set continuechar to item 2 of scan
set wholemessage to wholemessage & " " & item 3 of scan
end repeat
set errorCode to item 1 of scan as integer
if (errorCode ≥ 400) then
display dialog "Error: " & wholemessage
error wholemessage number errorCode
end if
end readresponse
-- Matches lines like:
-- 250 test... Sender ok
on scanline(lline)
return {characters 1 through 3 of lline as string, character 4 of lline as string, ¬
characters 5 through end of lline as string}
end scanline